<template>
    <div style="width: 100%;font-size: 14px;">
        <h1 style="margin-left: 40px;">项目名称：{{ formValue[current].project.project_name }}</h1>
        <div class="flex mt-20" v-for="(item, index) in form"
            :key="'form-item-' + index" >
            <p style="min-width: 140px;text-align: right; width: 140px;color: gray;">{{ getLabelName(item.option_key) }} :</p>
            <p class="ml-20" style="word-break:break-all;">{{ item.option_value }}</p>
        </div>
        <div class="flex" style="justify-content: flex-end;">
            <el-button @click="next" type="primary">{{ formValue.length>1? '下一张' + (current+1) + '/' + formValue.length:'确定' }}</el-button>
            <el-button @click="close">关闭</el-button>
        </div>
    </div>
</template>
<script>
export default {
    data(){
        return{
            current:0,
            list:[]
        }
    },
    props: {
        formValue: Array
    },
    computed:{
        form(){
            let desc = []
            try{
                desc = JSON.parse(this.formValue[this.current].desc)
            }catch{
                desc = []
            }
            return desc
        }
    },
    filters: {
        valueFilter(value) {
            return Array.isArray(value) ? value.join('、') : value
        }
    },
    created(){
        this.getList()
    },
    methods:{
        async getList(){
            let res = await this.$post({
                url: '/admin/formoption.FormOption/index',
                loadingTip: true,
            })
            res.list.forEach((item) => {
                item.select_json = JSON.parse(item.select_json)
                item.value = item.control_type == 2 ? [] : null
            })
            this.list = res.list
        },
        getLabelName:function(value){
            return this.list.length && this.list.find((item)=>item.s_key == value).label_name
        },
        next(){
            if(this.current+1 <= this.formValue.length-1){
                this.current++
            }else{
                this.close()
            }
        },
        close(){
            this.$emit('close')
        }
    }
}
</script>